const ak = 'IMSqvrji0t6o4g7B8vSb4ZFZ'

/**
 * @Description 异步加载百度地图
 * @date 2021-03-09
 * @param {any} ak:string
 * @returns {any}
 */
export function BMPGL() {
    return new Promise(function (resolve, reject) {
        try {
            console.log('BMap is defined:', BMapGL === undefined || BMapGL)
            resolve(BMapGL)
        } catch (err) {
            window.init = function () {
                resolve(BMapGL)
            }
            const script = document.createElement('script')
            script.type = 'text/javascript'
            script.src = `http://api.map.baidu.com/api?v=1.0&type=webgl&ak=${ak}&callback=init`
            script.onerror = reject
            document.head.appendChild(script)
        }
    })
}

/**
 * @Description 加载百度地图相关工具
 * @date 2021-03-09
 * @returns {any}
 */
export function MPGL() {
    return BMPGL().then(BMapGL => {
        let loaded = false
        try {
            loaded = mapvgl
        } catch (err) {
            loaded = false
        }
    })
}